package com.ww.core.utils;

import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;

public class DbUtils {

	public static void main(String[] args) {
		/*
		 * ApplicationContext context = new
		 * ClassPathXmlApplicationContext("applicationContext.xml");
		 * AnnotationSessionFactoryBean bean = (AnnotationSessionFactoryBean)
		 * context.getBean("&sessionFactory"); bean.updateDatabaseSchema();
		 */
		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		// 因为是FeactoryBean，所以要用"&sessionFactory"来获得
		AnnotationSessionFactoryBean asfb = (AnnotationSessionFactoryBean) context.getBean("&sessionFactory");
		SchemaExport se = new SchemaExport(asfb.getConfiguration());
		se.create(true, false);
	}

}
